<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="" prop="drivingMethod">
        <el-input
          v-model="queryParams.drivingMethod"
          placeholder="请输入驱动方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="" prop="updateStartTime">
        <el-date-picker
          clearable
          v-model="queryParams.updateStartTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择执行开始时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="updateEndTime">
        <el-date-picker
          clearable
          v-model="queryParams.updateEndTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择执行结束时间"
        >
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="" prop="updateTimeSpent">
        <el-input
          v-model="queryParams.updateTimeSpent"
          placeholder="请输入执行花费时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="" prop="updateDescription">
        <el-input
          v-model="queryParams.updateDescription"
          placeholder="请输入更新说明"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="" prop="updateStartDate">
        <el-date-picker
          clearable
          v-model="queryParams.updateStartDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择数据更新开始日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="dataUpdateEndDate">
        <el-date-picker
          clearable
          v-model="queryParams.dataUpdateEndDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择数据更新结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="excelId">
        <el-input
          v-model="queryParams.excelId"
          placeholder="请输入EXCELID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
      <br />

      <el-form-item label="驱动方式">
        <el-radio-group
          v-model="queryParams.drivingMethod"
          size="small"
          fill="#66b1ff"
          @change="getList"
        >
          <el-radio :label="null">所有记录</el-radio>
          <el-radio :label="'EXCEL'">EXCEL</el-radio>
          <el-radio :label="'API'">API</el-radio>
          <el-radio :label="'TASK'">定时器</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['conf:BiTaskList:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['conf:BiTaskList:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['conf:BiTaskList:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['conf:BiTaskList:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button plain size="mini" @click="handleexecute">执行</el-button>
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="BiTaskListList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="驱动方式" align="center" prop="drivingMethod">
        <template slot-scope="scope">
          {{ scope.row.drivingMethod | state1 }}
        </template>
      </el-table-column>
      <el-table-column
        label="任务说明"
        align="center"
        prop="taskDescription"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="执行开始时间"
        align="center"
        prop="updateStartTime"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="执行结束时间"
        align="center"
        prop="updateEndTime"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="执行花费时间"
        align="center"
        prop="updateTimeSpent"
      />
      <el-table-column
        label="更新说明"
        align="center"
        prop="updateDescription"
      />
      <el-table-column label="执行状态" align="center" prop="executionStatus" />
      <el-table-column
        label="数据更新开始日期"
        align="center"
        prop="updateStartDate"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="数据更新结束日期"
        align="center"
        prop="dataUpdateEndDate"
        width="180"
      >
      </el-table-column>

      <el-table-column
        label="计划更新开始日期"
        align="center"
        prop="planUpdateStartDate"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="计划更新结束日期"
        align="center"
        prop="planUpdateEndDate"
        width="180"
      >
      </el-table-column>
      <el-table-column
        label="计划更新最近N天"
        align="center"
        prop="lastUpdatedDays"
      >
      </el-table-column>
      <el-table-column
        label="计划时间优先方式"
        align="center"
        prop="planTimePriorityMethod"
      >
        <template slot-scope="scope">
          {{ scope.row.planTimePriorityMethod | state2 }}
        </template>
      </el-table-column>
      <el-table-column label="EXCELID" align="center" prop="excelId">
        <template v-slot="scope">
          <span
            style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
              font-weight: bold;
            "
            @click="handleEXCELID(scope.row, 5)"
            >{{ scope.row.excelId }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="配置任务明细" align="center" prop="excelId">
        <template v-slot="scope">
          <span
            style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
              font-weight: bold;
            "
            @click="selectformisNew(scope.row, 10)"
            >配置任务明细</span
          >
        </template>
      </el-table-column>
      <el-table-column label="定时器配置" align="center" prop="excelId">
        <template v-slot="scope">
          <span
            style="
              color: rgb(37, 137, 255);
              cursor: pointer;
              text-decoration: underline;
              font-weight: bold;
            "
            @click="handleformView(scope.row)"
            >定时器配置</span
          >
        </template>
      </el-table-column>

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['conf:BiTaskList:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['conf:BiTaskList:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 任务日志详细 -->
    <el-dialog
      title="定时器配置"
      :visible.sync="openView"
      width="800px"
      append-to-body
    >
      <el-form
        ref="formView"
        :model="formView"
        label-width="120px"
        v-if="openView"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="任务名称" prop="jobName">
              <el-input
                v-model="formView.jobName"
                placeholder="请输入任务名称"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="任务分组" prop="jobGroup">
              <el-select
                v-model="formView.jobGroup"
                placeholder="请选择任务分组"
              >
                <el-option
                  v-for="dict in dict.type.sys_job_group"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item prop="invokeTarget">
              <span slot="label">
                调用方法
                <el-tooltip placement="top">
                  <div slot="content">
                    Bean调用示例：ryTask.ryParams('ry')
                    <br />Class类调用示例：com.ruoyi.quartz.task.RyTask.ryParams('ry')
                    <br />参数说明：支持字符串，布尔类型，长整型，浮点型，整型
                  </div>
                  <i class="el-icon-question"></i>
                </el-tooltip>
              </span>
              <el-input
                v-model="formView.invokeTarget"
                placeholder="请输入调用目标字符串"
              />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="cron表达式" prop="cronExpression">
              <el-input
                v-model="formView.cronExpression"
                placeholder="请输入cron执行表达式"
              >
                <template slot="append">
                  <el-button type="primary" @click="handleShowCron">
                    生成表达式
                    <i class="el-icon-time el-icon--right"></i>
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="执行策略" prop="misfirePolicy">
              <el-radio-group v-model="formView.misfirePolicy" size="small">
                <el-radio-button label="1">立即执行</el-radio-button>
                <el-radio-button label="2">执行一次</el-radio-button>
                <el-radio-button label="3">放弃执行</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否并发" prop="concurrent">
              <el-radio-group v-model="formView.concurrent" size="small">
                <el-radio-button label="0">允许</el-radio-button>
                <el-radio-button label="1">禁止</el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态">
              <el-radio-group v-model="formView.status">
                <el-radio
                  v-for="dict in dict.type.sys_job_status"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormView">确 定</el-button>
        <el-button @click="cancelView">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="Cron表达式生成器"
      :visible.sync="openCron"
      append-to-body
      destroy-on-close
      class="scrollbar"
    >
      <crontab
        @hide="openCron = false"
        @fill="crontabFill"
        :expression="expression"
      ></crontab>
    </el-dialog>

    <!-- 添加或修改BI任务器对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-form-item label="驱动方式" prop="drivingMethod">
          <!-- <el-input v-model="form.drivingMethod" placeholder="请输入驱动方式" /> -->
          <el-select
            v-model="form.drivingMethod"
            clearable
            placeholder="请输入驱动方式"
          >
            <el-option
              v-for="item in tablecomment"
              :key="item.value"
              :label="`${item.label}`"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="执行开始时间" prop="updateStartTime">
          <el-date-picker
            clearable
            v-model="form.updateStartTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择执行开始时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="执行结束时间" prop="updateEndTime">
          <el-date-picker
            clearable
            v-model="form.updateEndTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择执行结束时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="执行花费时间" prop="updateTimeSpent">
          <el-input
            v-model="form.updateTimeSpent"
            placeholder="请输入执行花费时间"
          />
        </el-form-item>
        <el-form-item label="更新说明" prop="updateDescription">
          <el-input
            v-model="form.updateDescription"
            placeholder="请输入更新说明"
          />
        </el-form-item>
        <el-form-item label="数据更新开始日期" prop="updateStartDate">
          <el-date-picker
            clearable
            v-model="form.updateStartDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择数据更新开始日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="数据更新结束日期" prop="dataUpdateEndDate">
          <el-date-picker
            clearable
            v-model="form.dataUpdateEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择数据更新结束日期"
          >
          </el-date-picker>
        </el-form-item> -->
        <el-form-item
          label="计划更新开始日期"
          prop="planUpdateStartDate"
          v-if="form.drivingMethod != 'EXCEL'"
        >
          <el-date-picker
            clearable
            v-model="form.planUpdateStartDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划更新开始日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="计划更新结束日期"
          prop="planUpdateEndDate"
          v-if="form.drivingMethod != 'EXCEL'"
        >
          <el-date-picker
            clearable
            v-model="form.planUpdateEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划更新结束日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="计划更新最近N天"
          prop="lastUpdatedDays"
          v-if="form.drivingMethod != 'EXCEL'"
        >
          <el-input
            v-model="form.lastUpdatedDays"
            placeholder="请输入计划更新最近N天"
          />
        </el-form-item>
        <el-form-item
          label="计划时间优先方式"
          prop="planTimePriorityMethod"
          v-if="form.drivingMethod != 'EXCEL'"
        >
          <!-- <el-input v-model="form.excelId" placeholder="请输入EXCELID" /> -->
          <el-select
            v-model="form.planTimePriorityMethod"
            clearable
            filterable
            placeholder="请输入计划时间优先方式"
          >
            <el-option
              v-for="item in planTimePriorityMethodList"
              :key="item.value"
              :label="`${item.label}`"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="EXCELID"
          prop="excelId"
          v-if="form.drivingMethod == 'EXCEL'"
        >
          <el-input v-model="form.excelId" placeholder="请输入EXCELID" />
          <!-- <el-select
            v-model="form.excelId"
            clearable
            filterable
            placeholder="请输入EXCELID"
          >
            <el-option
              v-for="item in BiTableRelationshipConfigList"
              :key="item.id"
              :label="`${item.remark}`"
              :value="item.id"
            >
            </el-option>
          </el-select> -->
          <el-button @click="handleEXCELID(form, 15)" size="mini">
            EXCELID配置
          </el-button>
        </el-form-item>
        <el-form-item label="任务说明" prop="taskDescription">
          <el-input
            v-model="form.taskDescription"
            placeholder="请输入任务说明"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :visible.sync="openBiTableRelationshipConfig"
      width="1500px"
      append-to-body
      v-if="openBiTableRelationshipConfig"
    >
      <component :is="currentComponent" :id="id"></component>
    </el-dialog>

    <el-dialog
      :visible.sync="openEXCELID"
      width="1500px"
      append-to-body
      v-if="openEXCELID"
    >
      <BiTableRelationshipConfig
        :id="id"
        @pickEXCELID="pickEXCELID"
      ></BiTableRelationshipConfig>
    </el-dialog>
  </div>
</template>

<script>
import {
  listJob,
  getJob,
  delJob,
  addJob,
  updateJob,
  runJob,
  changeJobStatus,
} from "@/api/monitor/job";
import BiTableRelationshipConfig from "@/views/conf/BiTableRelationshipConfig/index.vue";
import BiTaskConfigDetail from "@/views/conf/BiTaskConfigDetail/index.vue";
import {
  listBiTaskList,
  getBiTaskList,
  delBiTaskList,
  addBiTaskList,
  updateBiTaskList,
  execute,
  taskById,
} from "@/api/conf/BiTaskList";
import {
  listBiTableRelationshipConfig,
  getBiTableRelationshipConfig,
  delBiTableRelationshipConfig,
  addBiTableRelationshipConfig,
  updateBiTableRelationshipConfig,
  processData,
} from "@/api/conf/BiTableRelationshipConfig";
import Crontab from "@/components/Crontab";
export default {
  name: "BiTaskList",
  dicts: ["sys_job_group", "sys_job_status"],
  components: {
    Crontab,
    BiTableRelationshipConfig,
    BiTaskConfigDetail,
  },
  data() {
    return {
      row: {},
      openEXCELID: false,
      expression: "",
      openCron: false,
      openView: false,
      formView: {
        jobId: undefined,
        misfirePolicy: 1,
        concurrent: 1,
        status: "0",
      },
      BiTableRelationshipConfigList: [],
      openBiTableRelationshipConfig: false,
      id: 0,
      tablecomment: [
        {
          label: "EXCEL",
          value: "EXCEL",
        },
        { label: "定时器", value: "TASK" },
        {
          label: "API",
          value: "API",
        },
      ],
      // 自定义：DEFINE/ 最近N天：LASTNDAYS
      planTimePriorityMethodList: [
        {
          label: "自定义",
          value: "DEFINE",
        },
        { label: "最近N天", value: "LASTNDAYS" },
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // BI任务器表格数据
      BiTaskListList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        drivingMethod: null,
        updateStartTime: null,
        updateEndTime: null,
        updateTimeSpent: null,
        updateDescription: null,
        executionStatus: null,
        updateStartDate: null,
        dataUpdateEndDate: null,
        excelId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      panelType: 5,
    };
  },
  filters: {
    state1(string) {
      if (string == "EXCEL") {
        return "EXCEL";
      }
      if (string == "API") {
        return "API";
      }
      if (string == "TASK") {
        return "定时器";
      }
    },
    // 自定义：DEFINE/ 最近N天：LASTNDAYS
    state2(string) {
      if (string == "DEFINE") {
        return "自定义";
      }
      if (string == "LASTNDAYS") {
        return "最近N天";
      }
    },
  },
  created() {
    this.getList();
    listBiTableRelationshipConfig({ pageNum: 1, pageSize: 100 }).then(
      (response) => {
        this.BiTableRelationshipConfigList = response.rows;
      }
    );
  },
  computed: {
    // ...mapGetters(["userId"]),
    currentComponent() {
      let type = parseInt(this.panelType);
      switch (type) {
        // case 5:
        //   return "BiTableRelationshipConfig";
        case 10:
          return "BiTaskConfigDetail";

        // case 20:
        //   return "BiVueLayoutInfo";
        default:
          return "";
      }
    },
  },
  methods: {
    /** cron表达式按钮操作 */
    handleShowCron() {
      this.expression = this.formView.cronExpression;
      this.openCron = true;
    },
    /** 确定后回传值 */
    crontabFill(value) {
      this.formView.cronExpression = value;
    },
    cancelView() {
      this.openView = false;
    },
    /** 提交按钮 */
    submitFormView: function () {
      this.$refs["formView"].validate((valid) => {
        if (valid) {
          if (this.formView.jobId != undefined) {
            updateJob(this.formView).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.openView = false;
              this.getList();
            });
          } else {
            addJob(this.formView).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.openView = false;
              this.getList();
            });
          }
        }
      });
    },
    handleformView(row) {
      const id = row.id || this.ids;
      taskById(id).then((response) => {
        if (!response.data) {
          this.formView.jobName = "任务器(" + row.id + "L)";
          this.formView.invokeTarget = "ryTask.runBiTaskId(" + row.id + "L)";
          this.formView.cronExpression = undefined;
          this.formView.jobId = undefined;
        } else {
          this.formView = response.data;
        }
        this.openView = true;
      });
    },
    pickEXCELID(id) {
      if (this.panelType == 15) {
        this.form.excelId = id;
        this.openEXCELID = false;
      } else {
        this.row.excelId = id;
        updateBiTaskList(this.row).then((response) => {
          this.$modal.msgSuccess("修改成功");
        });
        this.openEXCELID = false;
        this.getList();
      }
    },
    //open EXCELID弹窗
    handleEXCELID(row, panelType) {
      this.panelType = panelType;
      this.id = row.excelId;
      this.row = row;
      this.openEXCELID = true;
    },
    //配置任务明细弹窗
    selectformisNew(row, panelType) {
      this.panelType = panelType;
      if (this.panelType == 5) {
        this.id = row.excelId;
      } else {
        this.id = row.id;
      }

      this.openBiTableRelationshipConfig = true;
    },

    handleexecute() {
      if (this.ids.length != 1) {
        this.$modal.msgError("请只选择一条数据");
        return;
      } else {
        execute(this.ids[0]).then((response) => {
          if (response.code == 200) {
            this.$modal.msgSuccess("执行成功");
          }
        });
      }
    },
    /** 查询BI任务器列表 */
    getList() {
      this.loading = true;
      listBiTaskList(this.queryParams).then((response) => {
        this.BiTaskListList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        drivingMethod: null,
        updateStartTime: null,
        updateEndTime: null,
        updateTimeSpent: null,
        updateDescription: null,
        executionStatus: null,
        updateStartDate: null,
        dataUpdateEndDate: null,
        excelId: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加BI任务器";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getBiTaskList(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改BI任务器";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateBiTaskList(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBiTaskList(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除BI任务器编号为"' + ids + '"的数据项？')
        .then(function () {
          return delBiTaskList(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "conf/BiTaskList/export",
        {
          ...this.queryParams,
        },
        `BiTaskList_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
